package main

import (
	"database/sql"
	"fmt"
	"github.com/huandu/go-sqlbuilder"
)

func main()  {
	sb := sqlbuilder.NewSelectBuilder()
	innerSb := sqlbuilder.NewSelectBuilder()

	sb.Select("id", "name")
	sb.From(
		sb.BuilderAs(innerSb, "user"),
	)
	sb.Where(
		sb.In("status", sqlbuilder.Flatten([]int{1, 2, 3})...),
		sb.Between("created_at", sql.Named("start", 1234567890), sql.Named("end", 1234599999)),
	)
	sb.OrderBy("modified_at").Desc()

	innerSb.Select("*")
	innerSb.From("banned")
	innerSb.Where(
		innerSb.NotIn("name", sqlbuilder.Flatten([]string{"Huan Du", "Charmy Liu"})...),
	)
	sql, args := sb.Build()
	fmt.Println(sql)
	fmt.Println(args)
}